#pragma once
#include "windows.h"
#include <iostream>

namespace util
{
    namespace tool
    {
#ifdef _UNICODE
        static std::wostream &COUT = std::wcout;
#else
        static std::ostream &COUT = std::cout;
#endif

        const int bufferSize = 512;

        static TCHAR lpErrorMessageBuffer[bufferSize];

        void PrintError(DWORD dwFlags,
                        LPCVOID lpSource,
                        DWORD dwMessageId,
                        DWORD dwLanguageId,
                        va_list *Arguments);

        void PrintError();

        template <typename T, typename ...Args>
        struct MultFunction{
            typedef T (*value)(Args ... arg);
        };

        template <class Interface>
        inline void SafeRelease(
            Interface **ppInterfaceToRelease)
        {
            if (*ppInterfaceToRelease != NULL)
            {
                (*ppInterfaceToRelease)->Release();
                (*ppInterfaceToRelease) = NULL;
            }
        }

    }
}
